////////////////////////////////////////////////////////////////////////////////
//      
//      Kingsoft File for shp routines file
//      
//      File      : shp_div.h
//      Comment   : simple html parser link obj class
//					
//      Create at : 2008-09-04
//      Create by : chenguicheng
//      
////////////////////////////////////////////////////////////////////////////////

#pragma once

#include "shpsupport.h"
#include "shp_img.h"

#define SHP_DIV_ITEM_KEY				TEXT("div")

class shp_div_item : public shp_img_item
{
public:

	shp_div_item()
	:m_clr_bg(CLR_INVALID),
	m_clr_border(CLR_INVALID),
	m_i_alpha(SHP_NO_ALPHA)
	{
	};

	~shp_div_item()
	{
		
	};

	//set_attribute( p, m )
	BEGIN_KEY_MAP()
		ADD_INT_KEY( L"alpha",		m_i_alpha )
		ADD_CLR_KEY( L"clr_bg",		m_clr_bg )
		ADD_CLR_KEY( L"clr_border",	m_clr_border)
		BASE_CLASS_PROCESS(shp_img_item)
	END_KEY_MAP()

	void init_rect( CRect& parent_rect )
	{
		__super::calc_rect( parent_rect );
	}

	void draw_item( shpdc& dc, CRect& draw_rect )
	{
		BOOL bInRect = RectInRect( draw_rect, get_item_rect() );
		if( m_clr_border != CLR_INVALID )
		{
			if( !bInRect )
				shp_draw::frame_rect( dc, draw_rect, m_clr_border, m_i_alpha );
		}

		if( m_clr_bg != CLR_INVALID )
		{
			CRect rect(draw_rect);
			if( m_clr_border != CLR_INVALID && !bInRect )
				rect.DeflateRect( 1,1,0,0 );

			shp_draw::fill_rect( dc, rect, m_clr_bg, m_i_alpha );
		}

		if( m_str_skin.GetLength() > 0 )
			shp_img_item::draw_img( dc, draw_rect );
	}

	bool hit_test( UINT umsg, int x, int y, DWORD& dw_id )
	{
		return NO_PROCESS;
	}
	

private:

	shpclr	m_clr_border;
	shpclr	m_clr_bg;
	int		m_i_alpha;

};

